package com.gxks.lhs.controller.admin;


import com.gxks.lhs.constants.R;
import com.gxks.lhs.entity.Imgs;
import com.gxks.lhs.service.IImgsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 图片存放地址表 前端控制器
 * </p>
 *
 * @author LuoHaisong
 * @since 2023-06-05
 */
@RestController
@RequestMapping("/imgs")
public class ImgsController {

    @Autowired
    private IImgsService imgsService;

    @ApiOperation("商品图片批量上传")
    @PostMapping("/goods")
    public R goods(@RequestBody List<Imgs> imgsList) {
        if (imgsService.addGoodsImgs(imgsList)) {
            return R.success().setMsg("插入成功");
        }
        return R.error("插入失败");
    }

    @ApiOperation("评论图片批量上传")
    @PostMapping("/evaluate")
    public R evaluate(@RequestBody List<Imgs> imgsList) {
        if (imgsService.addEvaluateImgs(imgsList)) {
            return R.success().setMsg("插入成功");
        }
        return R.error("插入失败");
    }

    @ApiOperation("举报图片批量上传")
    @PostMapping("/report")
    public R report(@RequestBody List<Imgs> imgsList) {
        if (imgsService.addReportImgs(imgsList)) {
            return R.success().setMsg("插入成功");
        }
        return R.error("插入失败");
    }

}

